<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">商家列表</div>
                </div>
                <div class="widget-body am-fr">
					<!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <div class="am-u-sm-12 am-u-md-3">
							<div class="am-form-group">
								<div class="am-btn-group am-btn-group-sm">
									<a class="am-btn am-btn-primary am-radius" href="{:url('shop/add')}">
										<span class="am-icon-plus"></span> 新增
									</a>
								</div>
							</div>
						</div>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-hover tpl-table-black">
                            <thead>
                            <tr>
                                <th>编号ID</th>
                                <th>商家LOGO</th>
                                <th>商家名称</th>
                                <th>联系人</th>
                                <th>联系电话</th>
								<th>营业时间</th>
                                <th>门店码</th>
                                <th>买单码</th>
                                <th>外卖状态</th>
								<th>营业状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if !$list->isEmpty()}
                                {foreach $list as $index => $item}
                                <tr>
                                    <td class="am-text-middle">{$item['shop_id']}</td>
                                    <td class="am-text-middle">
                                        <img src="{$item['logo']['url']}" width="50" height="50" alt="门店图片">
                                    </td>
                                    <td class="am-text-middle">
                                        <p class="item-title">{$item['shop_name']}</p>
                                    </td>
                                    <td class="am-text-middle">{$item['linkman']}</td>
                                    <td class="am-text-middle">{$item['phone']}</td>
                                    <td class="am-text-middle">{$item['shop_hours']}</td>
									<td class="am-text-middle">
                                        <a class="hema-qrcode" data-index="{$index}" href="javascript:;">
                                        <i class="iconfont iconerweima" style="font-size:25px;color:#2979ff;"></i>
                                        </a>
                                    </td>
                                    <td class="am-text-middle">
                                        <a class="hema-paybill" data-index="{$index}" href="javascript:;">
                                        <i class="iconfont iconerweima" style="font-size:25px;color:#2979ff;"></i>
                                        </a>
                                    </td>
                                    <td class="am-text-middle">
                                            <span class="hema-takeout am-badge x-cur-p {$item['is_takeout']['value'] ? ' am-badge-success' : ''}" 
                                                 data-id="{$item['shop_id']}"
                                                 data-status="{$item['is_takeout']['value']}">
                                            {$item['is_takeout']['text']}
                                            </span>
                                    </td>
                                    <td class="am-text-middle">
                                            <span class="hema-status am-badge x-cur-p {$item['status']['value'] ? ' am-badge-success' : ''}" 
                                                 data-id="{$item['shop_id']}"
                                                 data-status="{$item['status']['value']}">
                                            {$item['status']['text']}
                                            </span>
                                    </td>
                                    <td class="am-text-middle">{$item['create_time']}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="{:url('shop/edit',['id' => $item['shop_id']])}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="hema-del tpl-table-black-operation-del"
                                               data-id="{$item['shop_id']}">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="12" class="am-text-center">暂无记录</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr">{:$list->render()} </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：{:$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="shop/qrcode" /}
<script>
    $(function () {
        let list = <?= json_encode($list)?>;
        $('.hema-qrcode').click(function () {
            let data = $(this).data();
            $.showAction({
                    title: '门店码', 
                    area: '510px', 
                    content: template('tpl-qrcode', {qrcode:list.data[data.index].qrcode}), 
                    uCheck: true, 
                    btn: ['取消'],
                    success: function ($content) {
                    }, 
                    btn2: function ($content) {
                        return true;
                    }
                });
        });
        $('.hema-paybill').click(function () {
            let data = $(this).data();
            $.showAction({
                    title: '买单码', 
                    area: '510px', 
                    content: template('tpl-qrcode', {qrcode:list.data[data.index].paybill}), 
                    uCheck: true, 
                    btn: ['取消'],
                    success: function ($content) {
                    }, 
                    btn2: function ($content) {
                        return true;
                    }
                });
        });
		// 外卖状态
		$('.hema-takeout').click(function () {
		    var data = $(this).data();
			var msg = '确定要'+(parseInt(data.status) === 1 ? '关闭' : '开启')+'外卖服务？';
			$('.hema-takeout').del('id', "{:url('shop/takeout')}",msg);
		});
		// 门店状态
		$('.hema-status').click(function () {
		    var data = $(this).data();
			var msg = '确定要'+(parseInt(data.status) === 1 ? '暂停营业' : '开启营业')+'吗？';
			$('.hema-status').del('id', "{:url('shop/status')}",msg);
		});
		$('.hema-del').del('id', "{:url('shop/delete')}");// 删除元素
    });
</script>